<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;

class Order extends AdminController
{
	public function index()
	{
		$data = Db::field('*')->name('order')->paginate(10);
		// dump($data);die;
		return view('admin@order/index', ['data' => $data]);
	}


	public function delete($id)
	{
		// $id = input('get.id');
		$res = Db::field('status')->name('order')->where('id', $id)->find();
		if($res['status'] == 1){
			$res['status'] = 2;
		}else{
			return;
		}
		$data = Db::name('order')->where('id', $id)->update($res);
		if ($data > 0 ) {
			$info['status'] = true;
			$info['id'] = $id;
			$info['info'] = 'ID为' . $id . '的订单处理成功!';
		} else {
			$info['status'] = false;
			$info['id'] = $id;
			$info['info'] = 'ID为' . $id . '的订单处理失败!';
		}
		// JSON 返回
		return json($info);
	}

}